package com.hao.demo.zoo.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * @Description: TODO
 * @Author Hao
 * @Date 2021/6/2 17:17
 * @Version 2.0
 */
@Configuration
public class DbConfig {

    @Bean
    @RefreshScope //refresh
    @Primary
    @ConfigurationProperties(prefix = "spring.datasource")
    public DataSource dataSource() {
        return DataSourceBuilder.create().build(); //这种方法配置的hikari不起作用
    }

}
